package com.softeem.springbootdemo2.controller;

import com.softeem.springbootdemo2.entity.User;
import com.softeem.springbootdemo2.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;
    //查询
    @GetMapping("/user/list")
    public List<User> list(){
        return userService.list();
    }
    //增加
    @GetMapping("/user/add")
    public boolean addd(User user){
        return userService.save(user);
    }
    //修改
    @GetMapping("/user/update")
    public boolean update(User user){
        return userService.updateById(user);
    }
    //删除
    @GetMapping("/user/{id}")
    public boolean del(@PathVariable Integer id){
        return userService.removeById(id);
    }
}
